#include <iostream>

void bubbleSort(int *arr, int arr_len)
{
	if (arr_len <= 1)
	{
		return;
	}

	int ret;

	for (int i = 0; i < arr_len - 1; ++i)
	{
		for (int j = 0; j < arr_len - 1 - i; ++j)
		{
			if (arr[j] > arr[j+1])
			{
				ret  = arr[j];
				arr[j]   = arr[j+1];
				arr[j+1] = ret;
			}
		}
	}
}

int main(int argc, char const *argv[])
{
	const int size = 10;
	int arr[size]={0};

	printf("%s\n", "origin:");
	for (int i = 0; i < size; ++i)
	{
		arr[i] = rand()%100;
		printf(" %d ", arr[i]);
	}		
	int arr_len = sizeof(arr) / sizeof(int);

	bubbleSort(arr, size);

	printf("\n%s\n", "sorted:");
	for (int i = 0; i < size; ++i)
	{
		printf(" %d ", arr[i]);
	}

	printf("\n");

	return 0;
}